package com.ruoyi.project.check.controller;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.project.check.domain.HisCheckList;
import com.ruoyi.project.check.service.HisCheckListService;
import net.bytebuddy.implementation.bind.annotation.Default;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 控制层
 */
@RestController
@RequestMapping("/check")
public class HisCheckListController extends BaseController{
    @Autowired
    private HisCheckListService hisCheckListService;

    /**
     * 根据ID查询检查单
     * @param list 检查单号
     * @return
     */
    @GetMapping("/id/{list}")
    @PreAuthorize("@ss.hasPermi('check:edit:list')")
    public AjaxResult findAll(Integer list){
       return AjaxResult.success(hisCheckListService.findId(list));
    }

    /**
     * 根据检查状态查询
     * @param statusList 检查状态码
     * @return
     */
    @GetMapping("/status/{statusList}")
    @PreAuthorize("@ss.hasPermi('check:edit:list')")
    public AjaxResult statusList(Integer statusList){
        System.out.println(statusList);

        return AjaxResult.success(hisCheckListService.findStatus(statusList));
    }

    /**
     * 搜素所有检查项目的名称
     * @return
     */
    @GetMapping("/findName")
    public AjaxResult findName(String name){
        return AjaxResult.success(hisCheckListService.findName(name));
    }

    /**
     * 查询检查结果和结果图片
     * @param rrcid 检查单号
     * @return
     */
    @GetMapping("/findAll")
    @PreAuthorize("@ss.hasPermi('check:search:select')")
    public AjaxResult findResultPicture(Integer rrcid){
        return AjaxResult.success(hisCheckListService.findResultPicture(rrcid));
    }

    /**
     * 修改检查状态
     * @param data 内含检查单号和检查状态码
     * @return
     */
    @PostMapping("/alterStatus")
    public int alterStatus(@RequestBody HisCheckList data){
        System.out.println(data);
        return hisCheckListService.alterStatus(data.getRrcstatus(), data.getRrcid());
    }

}
